-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC added example to reorder levels #43134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello @Nikhil636! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-08-21 07:19:08 UTC |
pandas/core/frame.py
Outdated
-------- | ||
>>> df = pd.DataFrame( | ||
... {"name" : ['Rahul','Arijit']}, | ||
... index = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you name the levels? will be much more obvious what is happening.
pandas/core/frame.py
Outdated
90 CSE A Rahul | ||
77 EEE B Arijit | ||
|
||
>>> df.reorder_levels([0,2,1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use spaces between then numbers (pep)
you can see if you can enable the doc-string test for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have updated the example. Please review it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you haven't put spaces between the numbers, please check https://www.python.org/dev/peps/pep-0008/
... 'Grade':['C', 'B', 'A'], | ||
... } | ||
>>> df=pd.DataFrame(data, columns = ['Mark', 'Branch', 'Grade', 'Name']) | ||
>>> df.set_index(['Branch', 'Mark', 'Grade'], inplace = True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, can you please write this as df = df.set_index(['Branch', 'Mark', 'Grade'])
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok I will do the changes.
Added an example for reorder levels.